home *** CD-ROM | disk | FTP | other *** search
/ Magnum One / Magnum One (Mid-American Digital) (Disc Manufacturing).iso / d26 / typefast.arc / UTILS.C < prev    next >
Text File  |  1989-11-27  |  2KB  |  89 lines

  1. #include <stdio.h>
  2. #include <curses.h>
  3. #ifdef UNIX
  4. #   include <sys/signal.h>
  5. #endif
  6.  
  7. /* game - utilities
  8.  *
  9.  * by Steve Spearman
  10.  */
  11.  
  12. /********************************************************
  13.  *
  14.  *  error ()
  15.  * 
  16.  *  Error() halts with an error message which is passed
  17.  *  as an argument
  18.  ********************************************************/
  19.  
  20. int
  21. error(reason)
  22. char reason[];
  23. {
  24.     move(22,0);
  25.     clrtoeol();
  26.     printw("Fatal Game Error - %s\n",reason);
  27.     refresh();
  28.     nodelay(stdscr,FALSE); 
  29.     endwin();
  30.     exit(1);
  31. }
  32.  
  33. int
  34. goodbye()
  35. {
  36.     move(23,0);
  37.     refresh();
  38.     nodelay(stdscr,FALSE); 
  39.     endwin();
  40.     exit(0);
  41. }
  42.  
  43. int
  44. sighandle()
  45. {
  46.     error("Unexpected signal received");
  47. }
  48.  
  49. int
  50. initialize()
  51. {
  52.     initscr();    /* initialize screen*/
  53.     cbreak();    /* get characters in immediate mode*/
  54.     nodelay(stdscr,TRUE); 
  55.     noecho();     /* don't echo input */
  56.  
  57. #ifndef MSDOS
  58.     if (clear()==ERR)
  59.         error("Your terminal to too dumb");    /* clear the screen*/
  60.     if (clrtoeol()==ERR)
  61.         error("Your terminal to too dumb");    /* check for function*/
  62.     if (move(23,79)==ERR)
  63.         error("Your terminal to too small");    /* check for size*/
  64.     signal(SIGINT,sighandle);
  65.     signal(SIGQUIT,sighandle);
  66.     signal(SIGILL,sighandle);
  67.     signal(SIGBUS,sighandle);
  68.     signal(SIGTRAP,sighandle);
  69.     signal(SIGIOT,sighandle);
  70.     signal(SIGEMT,sighandle);
  71.     signal(SIGSEGV,sighandle);
  72.     signal(SIGSYS,sighandle);
  73.     signal(SIGTERM,sighandle);
  74. #else
  75.     clear();
  76. #endif
  77. }
  78.  
  79.  
  80. int
  81. mygetchar(c)
  82. int *c;
  83. {
  84.     if (read(0,c,1) <= 0)
  85.         return(0);
  86.     *c &= 0177;
  87.     return(1);
  88. }
  89.